<template>
  <div>
    <div class="system-user-search mb15">
				<el-input size="default" placeholder="输入设备名称" v-model="eqName" style="max-width: 180px"> </el-input>
				<el-button size="default" type="primary" @click="eqselect(pagess,sizess,eqName)" class="ml10">
					<el-icon>
						<ele-Search />
					</el-icon>
					查询
				</el-button>
								<el-button size="default" type="success" class="ml10" @click="dialogFormVisible = true">新增科室</el-button>

<el-dialog title="科室添加" :visible.sync="dialogFormVisible">
  <el-form :model="form">
    <el-form-item label="科室名称" :label-width="formLabelWidth">
      <el-input v-model="form.dpc_id" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备名称" :label-width="formLabelWidth">
      <el-input v-model="form.eq_name" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备价格" :label-width="formLabelWidth">
      <el-input v-model="form.eq_price" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备数量" :label-width="formLabelWidth">
      <el-input v-model="form.eq_number" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备编号" :label-width="formLabelWidth">
      <el-input v-model="form.eq_saplings" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备状态:正常,损坏" :label-width="formLabelWidth">
      <el-input v-model="form.eq_state" autocomplete="off"></el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消 添 加</el-button>
    <el-button type="primary" @click="add(form.dpc_id,form.eq_name,form.eq_price,form.eq_number,form.eq_saplings,form.eq_state)">确 定 添 加</el-button>
  </div>
</el-dialog>&nbsp;
        <template>
</template>
			</div>
      
      <el-table
      ref="singleTable"
    :data="pagination.records"
    border 
    style="width: 100%;height:505px" Id="id">
    <el-table-column  fixed prop="eqId"  label="设备id"   width="100"></el-table-column>
    <el-table-column  prop="eqName" label="设备名称"    width="300"> </el-table-column>
    <el-table-column   prop="eqPrice" label="设备价格"   width="130"> </el-table-column>
    <el-table-column  prop="eqNumber"  label="设备数量"   width="130">  </el-table-column>
    <el-table-column  prop="eqSaplings"  label="设备编号"   width="230">  </el-table-column>
    <el-table-column  prop="eqState"  label="设备状态"   width="150">
    <el-tooltip :content="'状态: ' + value" placement="top">
  <el-switch 
    v-model="value"
    active-color="#13ce66"
    inactive-color="#ff4949"
    active-value="正常"
    inactive-value="维护">
  </el-switch>
</el-tooltip>
      </el-table-column>
    <el-table-column fixed="right"  label="操作" width="200">
      <template slot-scope="scope">
     <el-popover
  placement="right"
  width="500"
  trigger="click">
  <el-table :data="gridData">
    <el-table-column width="90" property="eqrId" label="设备记录id"></el-table-column>
    <el-table-column width="80" property="eqNumber" label="设备数量"></el-table-column>
    <el-table-column width="90" property="eqPrice" label="设备价格"></el-table-column>
    <el-table-column width="160" property="eqPurchaseTime" label="设备添加时间"></el-table-column>
  </el-table>
  <el-button type="text" slot="reference"  @click="toggleSelection(scope.row)">查看记录</el-button>
</el-popover>&nbsp;&nbsp;&nbsp;
    <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
  <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :hide-on-single-page="true"
      :current-page="pagination.current"
		  :page-sizes="[8]"
		  :page-size="pagination.size"
		  layout="total,sizes, prev, pager, next, jumper"
		  :total="pagination.total">
    </el-pagination>
  </div>
    <!-- <el-button @click="list()"  >测速</el-button> -->
  </div>
</template>

<script>
import equip from '@/api/equips'

export default {
  name: 'deptList',
  methods:{
    //分页
        handleSizeChange(value) {
          this.pagination.size = value
          this.list(this.pagination.current,this.pagination.size);
       },
        handleCurrentChange(value) {
          this.pagination.current = value
          this.list(this.pagination.current,this.pagination.size);
       },
       list(pages,sizes){
          equip.selectequip(pages,sizes).then(resp=>{
          this.pagination=resp;
          console.log(this.pagination)
        });
       },
    
       eqselect(pagess,sizess,eqName){
         equip.selecteq(pagess,sizess,eqName).then(resp=>{
           this.pagination=resp;
           console.log(this.pagination)
         });
         },
         add(dpc_id,eq_name,eq_price,eq_number,eq_saplings,eq_state){
           equip.addeq(dpc_id,eq_name,eq_price,eq_number,eq_saplings,eq_state).then(resp=>{
             alert("添加成功");
         });
         },

         toggleSelection(pat){
           equip.selectequiprecords(pat.eqId).then(resp=>{
              this.gridData=resp;
              console.log(this.gridData)
           });
         }
  },
  data() {
      return {
        pagination:{},
        eqName:"",
        pagess:1,
        sizess:8,
        options: [{
          value:'',
          label:''
        }],
        value:'',
        gridData: [{
        }],
        formLabelWidth: '140px',
        dialogFormVisible: false,
        form: {
          dpc_id: '',
          eq_name: '',
          eq_price:'',
          eq_number:'',
          eq_saplings:'',
          eq_state:'',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        value: "正常",
      }
    },  
    mounted() {
        this.list(1,8);
    },
  };
  
      
</script>
